<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />

    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
    <!--[if lt IE 8]>
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
    <![endif]-->

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main-menu.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/debug.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/submenu.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main/header.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main/footer.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main/misc.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main/column2.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/stock/manage.css" />

    <title><?php echo CHtml::encode($this->pageTitle); ?></title>
    <link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/images/fav-icon.ico" />
</head>

<body>

<div class="container" id="page">

    <div id="header">
        <?php $this->renderPartial('/site/_header', array()); ?>
    </div><!-- header -->

    <div id="mainmenu">
        <?php
        $isAdmin = (isset(Yii::app()->user->role) && (Yii::app()->user->role==="admin"));
        $isStaff = (isset(Yii::app()->user->role) && (Yii::app()->user->role==="staff"));
        $controllerId = Yii::app()->controller->id;
        $actionId = Yii::app()->controller->action->id;
        $this->widget('zii.widgets.CMenu',array(
            'encodeLabel' => false,
            'items'=>array(
                // Home
                array(
                    'label' => 'Home',
                    'url'   => array('/site/index'),
                    'active'=> $controllerId == 'site' && $actionId == 'index',
                ),

                // Stock Data
                array(
                    'label' => CHtml::tag('span', array('class' => 'stock'), 'Stock Data'),
                    'url'   => array('/stock/index'),
                    'active'=> $controllerId == 'stock'  && ($actionId == 'index' || $actionId == 'importFromFile' || $actionId == 'importFromWeb' || $actionId == 'validation'),
                    'visible'=> $isStaff || $isAdmin,
                ),

                // Stock Reports
                array(
                    'label' => CHtml::tag('span', array('class' => 'stockReport'), 'Stock Report'),
                    'url'   => array('/stock/report'),
                    'active'=> $controllerId == 'stock'  && ($actionId == 'chart' || $actionId == 'formula' || $actionId == 'report'),
                ),
                
                // Account - Only for Admin
                array(
                    'label'=>'Account',
                    'url'=>array('/account/index'),
                    'active'=> $controllerId == 'account',
                    'visible'=> $isAdmin,
                ),
                
               /* // Company/Ticker
                array(
                    'label'=>'Company',
                    'url'=>array('/company/index'),
                    'active'=> $controllerId == 'company',
                    'visible'=> $isStaff || $isAdmin,
                ),
                
                // Exchanges - Only for Admin
                array(
                    'label'=>'Exchange',
                    'url'=>array('/exchanges/index'),
                    'active'=> $controllerId == 'exchanges',
                    'visible'=> $isStaff || $isAdmin,
                ),
                */
                //Portfolio
                array(
                  'label'=>'Portfolio',
                    'url'=>array('/portfolioname/index'),
                    'active'=> $controllerId == 'portfolio' || $controllerId == 'portfolioname',
                    'visible'=>!Yii::app()->user->isGuest,
                ),
                //Login
                array(
                    'label'=>'Login',
                    'url'=>array('/site/login'),
                    'active'=> $controllerId == 'site' && $actionId == 'login',
                    'visible'=>Yii::app()->user->isGuest,
                ),

                //Logout
                array(
                    'label'=>'Logout ('.Yii::app()->user->name.')',
                    'url'=>array('/site/logout'),
                    'visible'=>!Yii::app()->user->isGuest,
                )
            ),
        )); ?>
    </div><!-- mainmenu -->

    <div id="submenuWrapper">
        <?php
            $this->widget('zii.widgets.CMenu', array(
                'encodeLabel' => false, //do NOT parse the label's text into html entities i.e. keep it as-is
                'items'      => $this->menu, //items are retrieved from this controller's `menu` properties - so that we can customize it in `views` by using `$this->menu`
                'htmlOptions'=> array('class'=>'submenu'),
            ));
        ?>
    </div><!-- submenu -->

    <?php echo $content; ?>

    <div id="footer">
        <?php $this->renderPartial('/site/_footer', array()); ?>
    </div><!-- footer -->

</div><!-- page -->

</body>
</html>